<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="68px">
      <el-form-item label="号牌号码" prop="plateno">
        <el-input
          v-model="queryParams.plateno"
          placeholder="请输入号牌号码"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="档案编号" prop="fileno">
        <el-input
          v-model="queryParams.fileno"
          placeholder="请输入档案编号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="标志" prop="marks">
        <el-input
          v-model="queryParams.marks"
          placeholder="请输入标志"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="检验记录" prop="record">
        <el-input
          v-model="queryParams.record"
          placeholder="请输入检验记录"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="外廓尺寸" prop="externalsize">
        <el-input
          v-model="queryParams.externalsize"
          placeholder="请输入外廓尺寸"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="图片存放地址" prop="dlphoto">
        <el-input
          v-model="queryParams.dlphoto"
          placeholder="请输入图片存放地址"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="创建时间" prop="createtime">
        <el-date-picker clearable size="small" style="width: 200px"
          v-model="queryParams.createtime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="选择创建时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['tc:travellicenseauxiliary:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['tc:travellicenseauxiliary:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['tc:travellicenseauxiliary:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['tc:travellicenseauxiliary:export']"
        >导出</el-button>
      </el-col>
    </el-row>

    <el-table v-loading="loading" :data="travellicenseauxiliaryList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="用户id" align="center" prop="userid" />
      <el-table-column label="表id" align="center" prop="tlaid" />
      <el-table-column label="号牌号码" align="center" prop="plateno" />
      <el-table-column label="档案编号" align="center" prop="fileno" />
      <el-table-column label="核定载人数" align="center" prop="allownum" />
      <el-table-column label="总质量" align="center" prop="totalmass" />
      <el-table-column label="整备质量" align="center" prop="curbweight" />
      <el-table-column label="核定载质量" align="center" prop="loadquality" />
      <el-table-column label="标志" align="center" prop="marks" />
      <el-table-column label="检验记录" align="center" prop="record" />
      <el-table-column label="外廓尺寸" align="center" prop="externalsize" />
      <el-table-column label="准牵引总质量" align="center" prop="totalquasimass" />
      <el-table-column label="告警码" align="center" prop="recognizewarncode" />
      <el-table-column label="告警码说明" align="center" prop="recognizewarnmsg" />
      <el-table-column label="唯一请求ID" align="center" prop="requestid" />
      <el-table-column label="图片存放地址" align="center" prop="dlphoto" />
      <el-table-column label="创建时间" align="center" prop="createtime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createtime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['tc:travellicenseauxiliary:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['tc:travellicenseauxiliary:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改腾讯云-用户行驶证副页对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="用户id" prop="userid">
          <el-input v-model="form.userid" placeholder="请输入用户id" />
        </el-form-item>
        <el-form-item label="号牌号码" prop="plateno">
          <el-input v-model="form.plateno" placeholder="请输入号牌号码" />
        </el-form-item>
        <el-form-item label="档案编号" prop="fileno">
          <el-input v-model="form.fileno" placeholder="请输入档案编号" />
        </el-form-item>
        <el-form-item label="核定载人数" prop="allownum">
          <el-input v-model="form.allownum" placeholder="请输入核定载人数" />
        </el-form-item>
        <el-form-item label="总质量" prop="totalmass">
          <el-input v-model="form.totalmass" placeholder="请输入总质量" />
        </el-form-item>
        <el-form-item label="整备质量" prop="curbweight">
          <el-input v-model="form.curbweight" placeholder="请输入整备质量" />
        </el-form-item>
        <el-form-item label="核定载质量" prop="loadquality">
          <el-input v-model="form.loadquality" placeholder="请输入核定载质量" />
        </el-form-item>
        <el-form-item label="标志" prop="marks">
          <el-input v-model="form.marks" placeholder="请输入标志" />
        </el-form-item>
        <el-form-item label="检验记录" prop="record">
          <el-input v-model="form.record" placeholder="请输入检验记录" />
        </el-form-item>
        <el-form-item label="外廓尺寸" prop="externalsize">
          <el-input v-model="form.externalsize" placeholder="请输入外廓尺寸" />
        </el-form-item>
        <el-form-item label="准牵引总质量" prop="totalquasimass">
          <el-input v-model="form.totalquasimass" placeholder="请输入准牵引总质量" />
        </el-form-item>
        <el-form-item label="告警码" prop="recognizewarncode">
          <el-input v-model="form.recognizewarncode" placeholder="请输入告警码" />
        </el-form-item>
        <el-form-item label="告警码说明" prop="recognizewarnmsg">
          <el-input v-model="form.recognizewarnmsg" placeholder="请输入告警码说明" />
        </el-form-item>
        <el-form-item label="唯一请求ID" prop="requestid">
          <el-input v-model="form.requestid" placeholder="请输入唯一请求ID" />
        </el-form-item>
        <el-form-item label="图片存放地址" prop="dlphoto">
          <el-input v-model="form.dlphoto" placeholder="请输入图片存放地址" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listTravellicenseauxiliary, getTravellicenseauxiliary, delTravellicenseauxiliary, addTravellicenseauxiliary, updateTravellicenseauxiliary, exportTravellicenseauxiliary } from "@/api/tc/travellicenseauxiliary";

export default {
  name: "Travellicenseauxiliary",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 总条数
      total: 0,
      // 腾讯云-用户行驶证副页表格数据
      travellicenseauxiliaryList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        plateno: undefined,
        fileno: undefined,
        marks: undefined,
        record: undefined,
        externalsize: undefined,
        dlphoto: undefined,
        createtime: undefined
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询腾讯云-用户行驶证副页列表 */
    getList() {
      this.loading = true;
      listTravellicenseauxiliary(this.queryParams).then(response => {
        this.travellicenseauxiliaryList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        userid: undefined,
        tlaid: undefined,
        plateno: undefined,
        fileno: undefined,
        allownum: undefined,
        totalmass: undefined,
        curbweight: undefined,
        loadquality: undefined,
        marks: undefined,
        record: undefined,
        externalsize: undefined,
        totalquasimass: undefined,
        recognizewarncode: undefined,
        recognizewarnmsg: undefined,
        requestid: undefined,
        dlphoto: undefined,
        createtime: undefined
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.tlaid)
      this.single = selection.length!=1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加腾讯云-用户行驶证副页";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const tlaid = row.tlaid || this.ids
      getTravellicenseauxiliary(tlaid).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改腾讯云-用户行驶证副页";
      });
    },
    /** 提交按钮 */
    submitForm: function() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.tlaid != undefined) {
            updateTravellicenseauxiliary(this.form).then(response => {
              if (response.code === 200) {
                this.msgSuccess("修改成功");
                this.open = false;
                this.getList();
              } else {
                this.msgError(response.msg);
              }
            });
          } else {
            addTravellicenseauxiliary(this.form).then(response => {
              if (response.code === 200) {
                this.msgSuccess("新增成功");
                this.open = false;
                this.getList();
              } else {
                this.msgError(response.msg);
              }
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const tlaids = row.tlaid || this.ids;
      this.$confirm('是否确认删除腾讯云-用户行驶证副页编号为"' + tlaids + '"的数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return delTravellicenseauxiliary(tlaids);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        }).catch(function() {});
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有腾讯云-用户行驶证副页数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return exportTravellicenseauxiliary(queryParams);
        }).then(response => {
          this.download(response.msg);
        }).catch(function() {});
    }
  }
};
</script>